package yunwo.cn.yzstation.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhy.autolayout.utils.AutoUtils;


import java.util.List;

import yunwo.cn.yzstation.R;
import yunwo.cn.yzstation.bean.InventoryBean;

/**
 * Created by lao on 2017/8/23.
 */

public class IventoryLVadapter extends BaseAdapter {
    Context context;
    List<InventoryBean.DataBean.ListBean> mList;



    public IventoryLVadapter(Context context, List<InventoryBean.DataBean.ListBean> list ) {

        this.context = context;
        this.mList = list;
    }
    @Override
    public int getCount() {

        return mList == null ? 0 : mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
         ViewHold mViewHold;
        if (convertView == null) {

            mViewHold = new ViewHold();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_iventory, parent, false);
            mViewHold.mConsignor = (TextView) convertView.findViewById(R.id.consignor);
            mViewHold.mConsignorphone = (TextView) convertView.findViewById(R.id.consignorphone);
            mViewHold.mConsignee = (TextView) convertView.findViewById(R.id.consignee);
            mViewHold.mConsigneephone = (TextView) convertView.findViewById(R.id.consigneephone);
            mViewHold.mBeginOrganName = (TextView) convertView.findViewById(R.id.beginOrganName);
            mViewHold.mEndOrganName = (TextView) convertView.findViewById(R.id.endOrganName);
            convertView.setTag(mViewHold);
            AutoUtils.autoSize(convertView);
        }else {

             mViewHold = (ViewHold)convertView.getTag();
        }
        mViewHold.mConsignor.setText(mList.get(position).getConsignorName());
        mViewHold.mConsignorphone.setText(mList.get(position).getConsignorPhone());
        mViewHold.mConsignee.setText(mList.get(position).getConsigneeName());
        mViewHold.mConsigneephone.setText(mList.get(position).getConsigneePhone());
        mViewHold.mBeginOrganName.setText(mList.get(position).getBeginOrganName());
        mViewHold.mEndOrganName.setText(mList.get(position).getEndOrganName());

       /* mViewHold.mConsignor.setText(mList.get(position).getConsigneeName());
        mViewHold.mConsignee.setText(mList.get(position).getConsignorName());

        mViewHold.mConsignorphone.setText(mList.get(position).getConsigneePhone());
        mViewHold.mConsigneephone.setText(mList.get(position).getConsignorPhone());

        mViewHold.mBeginOrganName.setText(mList.get(position).getBeginOrganName());
        mViewHold.mEndOrganName.setText(mList.get(position).getEndOrganName());*/

        return convertView;
    }
    class ViewHold {
        private TextView mTrackingNumber;
        private TextView mConsignor;
        private TextView mConsignorphone;
        private TextView mConsignee;
        private TextView mConsigneephone;
        private TextView mBeginOrganName;
        private TextView mEndOrganName;
    }
}
